<?php
use HyperfStore\Route\Route;

Route::get('/config', 'IndexController@config');
Route::post('/search', 'IndexController@search');
Route::get('/search/{id}', 'IndexController@searchId');
Route::post('/code', 'IndexController@code');
Route::post('/login', 'IndexController@login');
Route::post('/register', 'IndexController@register');
Route::post('/password', 'IndexController@password');

Route::post('/upload', 'IndexController@upload');

Route::get('/product', 'ProductController@index');
Route::get('/product/menu', 'ProductController@menu');
Route::get('/product/info/{id}', 'ProductController@info');

// 支付回调
Route::post('/user/pay/notify/{id}', 'UserPayController@notify');
        
Route::middleware('auth')->group(function () {
    // 用户
    Route::get('/user', 'UserController@info');
    Route::get('/user/list', 'UserController@list');
    Route::get('/user/log', 'UserController@log');
    
    // 转帐日志
    Route::get('/user/transfer', 'UserTransferController@index');
    Route::middleware('user_limit')->group(function () {
        // 转帐操作
        Route::post('/user/transfer/discount/{id}', 'UserTransferController@discount');
        Route::post('/user/transfer/full/{id}', 'UserTransferController@full');
        Route::post('/user/transfer/full_discount', 'UserTransferController@fullDiscount');
    });
    
    // 申请开店
    Route::post('/shop', 'ShopController@index');
    Route::get('/shop/money', 'ShopController@money');
    
    // 收货地址
    Route::get('/user/address', 'UserAddressController@index');
    Route::get('/user/address/default', 'UserAddressController@default');
    Route::post('/user/address', 'UserAddressController@create');
    Route::put('/user/address/{id}', 'UserAddressController@update');
    Route::delete('/user/address/{id}', 'UserAddressController@delete');
    Route::post('/user/address/check/{id}', 'UserAddressController@check');
    
    // 订单
    Route::get('/order/user', 'OrderController@user');
    Route::middleware('user_limit')->group(function () {
        // 购买商品操作
        Route::post('/order/{id}', 'OrderController@index');
    });
    
    // 充值
    Route::get('/user/pay', 'UserPayController@index');
    Route::middleware('user_limit')->group(function () {
        Route::post('/user/pay', 'UserPayController@create');
        Route::post('/user/pay/{id}', 'UserPayController@pay');
        Route::get('/user/pay/no/{id}', 'UserPayController@no');
    });
    
    // 钱包
    Route::middleware('user_limit')->group(function () {
        Route::post('/user/wallet', 'UserWalletController@index');
        Route::post('/user/wallet/out', 'UserWalletController@out');
        Route::get('/user/wallet/red', 'UserWalletController@red');
        Route::post('/user/wallet/red/out', 'UserWalletController@redOut');
    });
});